<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@page import="java.util.ArrayList" %>
<%@ page import="java.io.PrintWriter" %>
<%@ page import="java.util.List" %>
<%@ page import="com.qq.model.Book" %>

<html>
  <head>
    <meta charset="UTF-8">
    <title>$Title$</title>
  </head>
  <body>
<%-- action写路径 对应的的的是post提交 --%>
     <form action="hello" method="post">
       <input type="submit">
     </form>

<%--  快捷方式--%>
  <%
      if (1>0){
          out.print("你是猪");
      }else {
          out.print("我是猪");
      }
  %>
<hr>
  <%
     if (1>2){
  %>
  天气不错
  <%
      }else {
  %>
天气晴????
<%
      }
%>
<hr>

  <%
      List<String> nameList = new ArrayList<>();
      nameList.add("张三");
      nameList.add("张si");
      nameList.add("张三");
      nameList.add("张三2");
      nameList.add("张三3");
      nameList.add("张三8");
      for (String name:nameList){
          out.print(name +"<br><br>");
      }
  %>
  <hr>
<h1>EL表达式写法</h1>
     <%
       out.print(4*7);
     %>
    <hr>
    <%=4*7%>
    <hr>
    ${4*7}
  <hr>
  <%
     int xxx=111;
     int yyy=333;
     out.print(xxx>yyy);
  %>
  <%=xxx>yyy%>
<h2>el表达式</h2>
  ${xxx>yyy}
  ${xxx eq yyy}
<hr>
  <%
   pageContext.setAttribute("name","jack");
   request.setAttribute("name","request");
   session.setAttribute("name","session");
   application.setAttribute("name","application");
  %>
   ${name}<br>
  ${applicationScope.name}
  <hr>
  <%
     request.setAttribute("nick","小明");
     request.setAttribute("age","100");
      Book book = new Book();
     request.setAttribute("book",new Book(5,"猪八戒","小明",50));
  %>
  ${age},${nick}<hr>
  ${book}<h1>进行单独打印</h1>
<%--这里的id和name、autho、price调用的是book实体类里面的getId、getName、getAuthor、getPrice方法--%>
  ${book.id},${book.name},${book.author},${book.price}

  </body>
</html>
